home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / MEMORY.SWG / 0068_Overlay Manager.pas < prev    next >
Pascal/Delphi Source File  |  1995-03-03  |  3KB  |  116 lines

  1. {
  2. -> I'm having a problem in a program that I'm doing. I need to make
  3. -> overlay files and I'm tying to put them in expanded memory with the
  4. -> instruction OvrInitEMS but after that the program leaves to DOS
  5. -> without doing any instruction else.
  6. -> If someone knows how to solve this problem, I would like some Help
  7.  
  8. > Which TP version and which DOS version?  I found that EMM386 from DOS
  9. > 6.2 didn't cooperate with some of my Borland products, so I killed DOS
  10. > 6.2.
  11.  
  12. Here's the source code of an overlay manager that I have been using for
  13. years without any problems.  It's based on the one found in the
  14. documentation.
  15. }
  16.  
  17. UNIT TNDOvrIn;
  18. {$O+}  { Enable overlaying of this unit }
  19. {$F+}  { Turn on Far Calls }
  20.  
  21. INTERFACE
  22.  
  23. IMPLEMENTATION
  24. USES Dos,
  25.      Crt,
  26.      Overlay;
  27.  
  28. CONST
  29.   OvrMaxSize = 128416;
  30.   {OvrMaxSize = 0;}
  31.  
  32. VAR
  33.   OvrName        : STRING[79];
  34.   Message        : BOOLEAN;
  35.  
  36. PROCEDURE PrintMsg(pInString : STRING);
  37. BEGIN
  38.   WRITELN( pInString );
  39. END;
  40.  
  41. BEGIN
  42.   PrintMsg( '' );
  43.   PrintMsg( 'Please wait for TNDM to load into memory.' );
  44.   PrintMsg( '' );
  45.  
  46.   Message := FALSE;
  47.   OvrName := 'TNDM.OVR';
  48.  
  49.   IF LO(DosVersion) >= 3 THEN
  50.     OvrName := ParamStr(0)
  51.   ELSE
  52.     BEGIN
  53.       OvrName := FSearch('TNDM.EXE', GetEnv('PATH') );
  54.       IF (OvrName = '') THEN
  55.         BEGIN
  56.         PrintMsg( 'The main program must be named "TNDM.EXE" and it must' );
  57.         PrintMsg( 'reside in your PATH or in the current directory.' );
  58.         END;
  59.     END;
  60.  
  61.   {WRITELN;}
  62.   OvrName := FExpand(OvrName);
  63.   {WRITELN('Loading ', OvrName, '...');}
  64.   DEC(OvrName[0], 3);
  65.   OvrName := OvrName + 'OVR';
  66.  
  67.  
  68.   REPEAT
  69.     OvrInit(OvrName);
  70.  
  71.     IF OvrResult = ovrNotFound THEN
  72.       BEGIN
  73.         PrintMsg( 'Overlay file not found: ' + OvrName );
  74.         WRITE('Enter correct overlay file name: ');
  75.         READLN(OvrName);
  76.       END;
  77.   UNTIL OvrResult <> ovrNotFound;
  78.  
  79.   IF OvrResult <> OvrOk THEN
  80.     BEGIN
  81.     PrintMsg( 'Overlay manager error.  Unable to continue.  Error loading overlay file.' );
  82.     Halt(1);
  83.     END;
  84.  
  85.   {WRITELN('Overlay manager has been installed.');}
  86.   PrintMsg( '' );
  87.  
  88.   OvrInitEMS;
  89.   IF OvrResult <> OvrOk THEN
  90.     BEGIN
  91.       CASE OvrResult OF
  92.         ovrIOError     :
  93.           BEGIN
  94.           PrintMsg( 'Overlay file I/O error.  Unable to continue.' );
  95.           HALT(1);
  96.           END;
  97.  
  98.         ovrNoEMSDriver : {WRITE('EMS driver not installed')};
  99.  
  100.         ovrNoEMSMemory : {WRITE('Not enough EMS memory')};
  101.  
  102.       END;
  103.  
  104.       {*-- Increase buffer only if no EMS --*}
  105.       OvrSetBuf(OvrGetBuf + OvrMaxSize);
  106.       OvrSetRetry(OvrGetBuf DIV 3);
  107.     END
  108.   ELSE
  109.     BEGIN
  110.       {*-- Some extra buffer is still needed --*}
  111.     OvrSetBuf(OvrGetBuf + OvrMaxSize );
  112.     OvrSetRetry(OvrGetBuf DIV 6);
  113.     END;
  114.  
  115. END.
  116.